cssprovider: Names starting with -gtk- aren't style props
authorBenjamin Otte <otte@redhat.com>
Mon, 16 Jun 2014 20:13:07 +0000 (22:13 +0200)
committerBenjamin Otte <otte@redhat.com>
Mon, 16 Jun 2014 22:01:25 +0000 (00:01 +0200)
We want to have the "-gtk-" prefix for our custom CSS properties. But
we also want to parse names starting with a "-" as style properties.
So make sure that "-gtk-" is treated like a normal property and we emit
errors when somebody uses it wrong.

This is to catch errors with people typing
  -gtk-iconsource: none;
instead of the correct
  -gtk-icon-source: none;

gtk/gtkcssprovider.c

index 242f1b932721c8c757f20f62efb708a54e26aff6..30881beda1dbe7740b5290f4d8dc1f424c7fb141 100644 (file)
@@ -2342,6 +2342,18 @@ parse_selector_list (GtkCssScanner *scanner)
   return selectors;
 }
 
+static gboolean
+name_is_style_property (const char *name)
+{
+  if (name[0] != '-')
+    return FALSE;
+
+  if (g_str_has_prefix (name, "-gtk-"))
+    return FALSE;
+
+  return TRUE;
+}
+
 static void
 parse_declaration (GtkCssScanner *scanner,
                    GtkCssRuleset *ruleset)
@@ -2356,7 +2368,7 @@ parse_declaration (GtkCssScanner *scanner,
     goto check_for_semicolon;
 
   property = _gtk_style_property_lookup (name);
-  if (property == NULL && name[0] != '-')
+  if (property == NULL && !name_is_style_property (name))
     {
       gtk_css_provider_error (scanner->provider,
                               scanner,
@@ -2441,7 +2453,7 @@ parse_declaration (GtkCssScanner *scanner,
 
       gtk_css_scanner_pop_section (scanner, GTK_CSS_SECTION_VALUE);
     }
-  else if (name[0] == '-')
+  else if (name_is_style_property (name))
     {
       char *value_str;